<template>
	<view>
		<view class="margin-xs padding bg-white flex solid-bottom bg-white" v-for="(item,index) in list.rows" :key="index">
		  <view class="flex-treble">
		    <view class="text-black">{{item.sourceName}}</view>
		    <view class="padding-top text-gray text-sm">{{item.creTm}}</view>
		  </view>
		   <view class="flex-sub text-lg padding-top text-center" :class="[item.entryType=='1'?'text-green':'text-orange']">
		    {{item.entryType=='1'?'+':'-'}}{{item.creditNum}}
		  </view> 
		</view>
		
		<view v-if="isLoad" class="cu-load text-gray loading"></view>
		<view v-else-if="list.rows.length < list.total" class="cu-load text-gray">已加载</view>
		<view v-else-if="list.rows.length==list.total && list.total!=0" class="cu-load text-gray over"></view>
		<view v-else="list.total==0" class="pos-center text-center text-gray">
			<text class="cuIcon-activityfill" style="font-size: 30px;"></text>
			<view class="">
				暂无数据
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLoad: false,
				list: [],
				queryData: {
					currPage: 1
				},
				currentCreditNum: 0
			};
		},
		onLoad() {
			this.getList();
		},
		// 下拉刷新
		onPullDownRefresh: function() {
			this.queryData.currPage = 1;
			let _this = this;
			setTimeout(function() {
				uni.stopPullDownRefresh();
				_this.getList();
			}, 1000);
		},
		// 上拉加载
		onReachBottom() {
			if(this.list.rows.length<this.list.total){
				this.queryData.currPage += 1;
				this.getList();
			}
		},
		methods: {
			getList(){
				this.isLoad = true;
				let _this = this;
				this.baseRequest('api/driver/credit/log', 'GET', this.queryData, function(res){
					if (res) {
						if (_this.queryData.currPage != 1) {
							_this.list.rows = _this.list.rows.concat(res.rows);
							_this.list.total = res.total;
						} else {
							_this.list = res;
						}
						_this.currentCreditNum=res.otherInfo.currentCreditNum; //
					} else {
						_this.list = {
							total: 0,
							rows: []
						};
					}
					_this.isLoad = false;
				});
			},
		}
	}
</script>